﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bing.Toolkit.Data
{
    public interface IPageOfList
    {
        Int32 ItemCount { get; }
        Int32 PageCount { get; }
        Int32 PageIndex { get; }
        Int32 PageSize { get; }
    }

    public class PageOfList<T> : List<T>, IPageOfList
    {
        public PageOfList(IEnumerable<T> items, int pageIndex, int pageSize, int itemCount)
        {
            AddRange(items);
            PageIndex = pageIndex;
            PageSize = pageSize;
            ItemCount = itemCount;
            PageCount = (int)Math.Ceiling(itemCount / (double)pageSize);
        }

        #region IPageOfList<T> 成员

        public int ItemCount { get; private set; }
        public int PageCount { get; private set; }
        public int PageIndex { get; private set; }
        public int PageSize { get; private set; }

        #endregion

    }
}
